package com.example.demo.contorller;

import com.example.demo.pojo.User;
import com.example.demo.service.UserCacheApiService;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author zhouzhenyuan
 */
@RestController
public class TestController {
    @Autowired
    UserService userService;

    @Autowired
    UserCacheApiService userCacheApiService;

    @GetMapping("/test1/{userId}")
    public User test1(@PathVariable String userId) {
        return  userService.getUserById(userId);
    }
    @GetMapping("/test1/{userId}/{email}")
    public User test1(@PathVariable String userId,@PathVariable String email) {
        return  userService.updateUserById(email,userId);
    }

    @GetMapping("/test2/{userId}")
    public User test2(@PathVariable String userId) {
        return  userCacheApiService.findById(userId);
    }
}
